<template>
  <div class="order" style="height: 100%;overflow: hidden;">
    <div class="common-form"style="height: 100%;">
      <div class="order-user">
        <div class="order-add-user">
          <label>收货人</label>
          <input type="text" placeholder="收货人" v-model="Consignee"/>
        </div>
        <div class="order-add-user">
          <label for="">手机号码</label>
          <input type="text" placeholder="手机号码"v-model="phone"/>
        </div>
        <div class="order-add-user"style="display: inline-block;justify-content: space-around;width: 100%;">
          <label for="">所在地区</label>
          <div class="city">
            <div class="city-list"style="position:relative;">
              <div @click="addv":style="styleObject">{{add}}</div>
              <ul style="width: 100%;height: 8rem;overflow: auto;background-color: white;position: absolute;left: -14px;top: 38px;" v-show="addE">
                <li v-for="(item,index) in Address"style="height: 2rem;width: 100%;text-align: center;" @click="sheng(index)">{{item.region_name}}</li>
              </ul>
            </div>
            <div class="city-list"style="position: relative;">
              <div @click="addv_2":style="styleObject2">&nbsp;{{add_2}}&nbsp;</div>
              <ul style="width: 100%;height: 8rem;overflow: auto;background-color: white;position: absolute;top: 38px;left: -9px;"v-show="addE_2">
                <li v-for="(item,index) in Address_1"style="height: 2rem;width: 100%;" @click="shi(index)">{{item.region_name}}</li>
              </ul>
            </div>
            <div class="city-list"style="position: relative;">
              <div @click="addv_3":style="styleObject3">&nbsp;{{add_3}}&nbsp;</div>
              <ul style="width: 100%;height: 8rem;overflow: auto;background-color: white;position:absolute;top: 38px;left: -8px;"v-show="addE_3">
                <li v-for="(item,index) in Address_2"style="height: 2rem;width: 100%;" @click="qu(index)">{{item.region_name}}</li>
              </ul>
            </div>
          </div>
        </div>
        <div class="order-add-user-textarea">
          <label for="">详细地址</label>
          <textarea placeholder="街道，居住地 等"v-model="address"></textarea>
        </div>
      </div>
    </div>
    <div class="footer-100"></div>
    <div style="width: 100%;height: 49px;line-height: 49px;text-align: center;color: #FFF;background: #FE2746;position: fixed;bottom: 0;left: 0;"@click="aler">保存使用</div>
  </div>
</template>

<script>
  import axios from 'axios';
  import Vue from 'vue';
  import { Picker } from 'mint-ui';
  Vue.component(Picker.name, Picker);
  export default {
    name: 'NewAddress',
    data(){
      return{
        Address:[],
        Address_1:[],
        Address_2:[],
        in:'',
        options2: [{
          value: '选项1',
          label: '黄金糕'
        }, {
          value: '选项2',
          label: '双皮奶',
          disabled: true
        }, {
          value: '选项3',
          label: '蚵仔煎'
        }, {
          value: '选项4',
          label: '龙须面'
        }, {
          value: '选项5',
          label: '北京烤鸭'
        }],
        value2: '',
        value3: '',
        sheng_id:'',
        shi_id:'',
        add:'省',
        addE:false,
        add_2:'市',
        addE_2:false,
        add_3:'区',
        addE_3:false,
        ecvaiD:'',
        ecvaiD_2:'',
        ecvaiD_3:'',
        Consignee:'',
        address:'',
        phone:'',
        DataID:[],

        id: this.$route.params.id,
        num: this.$route.params.num,
        styleObject: {
          'line-height': '38px',
          color: '#cccccc',
        },
        styleObject2: {
          'line-height': '38px',
          color: '#cccccc',
        },
        styleObject3: {
          'line-height': '38px',
          color: '#cccccc',
        }
      }
    },
    methods:{
      configData(index){
        console.log(index)
      },
      onValuesChange(picker, values) {
        if (values[0] > values[1]) {
          picker.setSlotValue(1, values[0]);
        }
      },
      sheng(index){
        console.log(index);
        this.sheng_id = index;
        axios.get('http://tshare.76sd.com/address/regionAll?', {
          params: {
            'company':'1',
            'sign':'1E907AA22797F1500A85738F5B44559B'
          },
        }).then(response =>{
          this.Address_1 = response.data.data[this.sheng_id].list;
          this.add = response.data.data[this.sheng_id].region_name
          // console.log(response.data.data[this.sheng_id].region_id);
          this.ecvaiD = response.data.data[this.sheng_id].region_id;
          this.styleObject.color = '#000'
        }).catch(function (error) {
          console.log(error);
        });
        this.addE = false;
      },
      shi(index){
        this.shi_id = index;
        axios.get('http://tshare.76sd.com/address/regionAll?', {
          params: {
            'company':'1',
            'sign':'1E907AA22797F1500A85738F5B44559B'
          },
        }).then(response =>{
          this.Address_2 = response.data.data[this.sheng_id].list[this.shi_id].list;
          console.log(this.Address_2)
          this.add_2 =this.Address_1[index].region_name;
          this.ecvaiD_2 = response.data.data[this.sheng_id].list[this.shi_id].region_id;
          this.styleObject2.color = '#000';
          if (this.Address_2 == ''){
            this.add_3 = ''
          }else {

          }
        }).catch(function (error) {
          console.log(error);
        });
        this.addE_2 = false;
      },
      qu(index){
        // console.log(this.Address_2[index].region_name);
        this.add_3 = this.Address_2[index].region_name;
        this.addE_3 = false;
        // console.log(this.Address_2[index].region_id);
        this.ecvaiD_3 = this.Address_2[index].region_id;
        // console.log(this.ecvaiD,this.ecvaiD_2,this.ecvaiD_3)
        this.styleObject3.color = '#000';
      },
      addv(){
        this.addE = true;
      },
      addv_2(){
        this.addE_2 = true;
      },
      addv_3(){
        this.addE_3 = true;
      },
      aler() {
        this.DataID.push({ecvaiD:this.ecvaiD,cvaiD_2:this.ecvaiD_2,ecvaiD_3:this.ecvaiD_3,consignee:this.Consignee,address:this.address,phone:this.phone,num:this.num,id:this.id});
        var addres = JSON.stringify(this.DataID);
        addStorage("addres", addres);
        if (this.ecvaiD == '' || this.ecvaiD_2 == '' ||  this.Consignee == '' || this.address == '' || this.phone.length != 11){
          this.$message.error('错了哦，手机号输入错误');
        } else {
          this.$router.push({name: 'Order', params: {ecvaiD:this.ecvaiD,cvaiD_2:this.ecvaiD_2,ecvaiD_3:this.ecvaiD_3,consignee:this.Consignee,address:this.address,phone:this.phone,num:this.num,id:this.id}});
        }
      }
    },
    watch:{
      value2(New,Old){
        console.log(New);

      },
      value3(Old,New){
        // alert(1)

        console.log(Old,New);
      },
    },
    created(){
      // alert(1)
      axios.get('http://tshare.76sd.com/address/regionAll?', {
        params: {
          'company':'1',
          'sign':'1E907AA22797F1500A85738F5B44559B'
        },
      }).then(response =>{
        this.Address = response.data.data;
        let odd = []
        for (var i=0; i<this.Address.length; i++){
          this.Address_1 = this.Address[i].list;
        }
        console.log(odd);
      }).catch(function (error) {
        console.log(error);
      });
console.log(this.id,this.num)
    }
  }
  function addStorage(addres,value){
    localStorage.removeItem(addres);
    localStorage.setItem(addres,value);
  }

  function removeStorage(addres){
    localStorage.removeItem(addres);
  }

  function getStorage(addres) {
    var storage = window.localStorage;
    var val = storage.getItem(addres);
    return val;
  }
</script>

<style scoped>
  *{
    margin:0px;
    padding:0px;
    font-family:"微软雅黑","Microsoft YaHei";
    font-size:14px;
    color:#101010;
  }
.city{
    width: 70%;
    display: inline-block;
    margin-left: 10px;
}
.city-list{
  float: left;
  width: 30%;
}
  input::placeholder{
    color: #cccccc;
  }
  textarea::placeholder{
    color: #cccccc;
  }
  body{
    width:100%;
    background:#f9f9f9;
  }
  em,i{
    font-style: normal;
  }
  a{
    text-decoration: none;
  }
  input,textarea{
    outline: none;
  }
  .left{
    float:left;
  }
  .right{
    float:right;
  }
  .footer-100{
    width:100%;
    height:60px;
    display: inline-block;
  }
  /*底部菜单*/
  .footer a{
    width:20%;
    text-align: center;
    float: left;
  }
  .footer a p{
    font-size:13px;
  }
  .footer a:nth-child(1) i{
    display: inline-block;
    height: 22px;
    width: 20px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//tab1-pink.png) no-repeat;
    background-size: 100%;
    margin-top: 5px;
    vertical-align: text-bottom;
  }
  .footer a:nth-child(2) i{
    display: inline-block;
    height: 22px;
    width: 18px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//tab2.png) no-repeat;
    background-size: 100%;
    margin-top: 5px;
    vertical-align: text-bottom;
  }
  .footer a:nth-child(3) i{
    display: inline-block;
    height: 22px;
    width: 20px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//tab3.png) no-repeat;
    background-size: 100%;
    margin-top: 5px;
    vertical-align: text-bottom;
  }
  .footer a:nth-child(4) i{
    display: inline-block;
    height: 22px;
    width: 20px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//tab4.png) no-repeat;
    background-size: 100%;
    margin-top: 5px;
    vertical-align: text-bottom;
  }
  .footer a:nth-child(5) i{
    display: inline-block;
    height: 22px;
    width: 20px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//tab5.png) no-repeat;
    background-size: 100%;
    margin-top: 5px;
    vertical-align: text-bottom;
  }
  /*商品数量*/
  .goods-num{
    margin-top: 15px;
    display: inline-block;
  }
  .add,.sub{
    font-size:20px;
    float: left;
    width:25px;
    height:25px;
    line-height: 25px;
    text-align: center;
  }
  .num{
    float: left;
  }
  .num input{
    width: 45px;
    height: 25px;
    line-height: 25px;
    border-radius: 20px;
    background-color: rgba(254, 39, 70, 0.08);
    border:0;
    text-align: center;
    color:#FC2847;
  }
  /*通屏按钮*/
  .btn-big{
    width:100%;
    height:49px;
    line-height: 49px;
    text-align: center;
    color:#FFF;
    background: #FE2746;
    position: fixed;
    bottom:0;
    left:0;
  }
  .btn-big em{
    font-size:20px;
    color:#FFF;
    vertical-align: bottom;
  }
  /*轮播*/
  .banner img{
    width:100%;
  }
  /*公共边框*/
  .common-form{
    width:94%;
    margin:0 auto;
    background: #FFF;
    border-radius: 5px;
    margin-top:10px;
    overflow: hidden;
  }
  /*公共标题*/
  .common-tel{
    width:94%;
    margin:0 auto;
    margin-top:15px;
    color:#FE2746;
    font-size:15px;
    font-weight: 600;
    display: inline-block;
    margin-left: 3%;
  }
  .common-tel-dot em:nth-child(1){
    width: 12px;
    height: 2px;
    background: #FE2746;
    float: left;
    margin-top: 5px;
  }
  .common-tel-dot em:nth-child(2){
    width: 8px;
    height: 2px;
    background-color: rgba(254, 39, 70, 0.59);
    float: left;
    margin-top: 5px;
    margin-left: 6px;
  }
  .common-tel-dot em:nth-child(3){
    width: 6px;
    height: 2px;
    background-color: rgba(254, 39, 70, 0.3);
    float: left;
    margin-top: 5px;
    margin-left: 6px;
  }
  .common-tel a{
    color: #FE2746;
    float: right;
    font-size: 12px;
    font-weight: 100;
    margin-top: -13px;
  }
  .common-tel a i{
    color:#FE2746;
  }










  /*详情页面*/
  .detail-banner img{
    width:100%;
    height:355px;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
  }
  .detail-banner-dot{
    width:100%;
    display: inline-block;
    text-align: center;
  }
  .detail-banner-dot em{
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #CCC;
    display: inline-block;
    margin: 0 6px;
  }
  .detail-banner-dot-pink{
    background: #FE2746 !important;
  }
  .detail-tel,.detail-price,.detail-other{
    width:94%;
    margin:5px auto;
    line-height: 24px;
  }
  .detail-tel span{
    font-size: 12px;
    color: #999;
    float: right;
    margin-top: -17px;
  }
  .detail-tel span i{
    display: inline-block;
    height: 19px;
    width: 20px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//xin.png) no-repeat;
    background-size: 100%;
    margin-top: 5px;
    vertical-align: text-bottom;
  }
  .detail-price p:nth-child(1){
    font-size:12px;
    color:#999;
  }
  .detail-price p:nth-child(2){
    color: #FE2746;
    font-weight: 600;
    font-size: 14px;
  }
  .detail-price p:nth-child(2) em{
    color:#FE2746;
    font-size:18px;
  }
  .detail-other{
    display: inline-block;
    margin-left: 3%;
    margin-bottom: 2%;
  }
  .detail-other em{
    width:33.33%;
    float:left;
    color:#999;
    font-size:12px;
  }
  .detail-other em:nth-child(1){
    text-align: left;
  }
  .detail-other em:nth-child(2){
    text-align: center;
  }
  .detail-other em:nth-child(3){
    text-align: right;
  }
  .detail-service{
    padding:9px 8px;
    font-size:12px;
    color:#999;
  }
  .detail-service span{
    color:#FE2746;
    font-weight: 600;
  }
  .detail-service span em{
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #FE2746;
    display: inline-block;
    margin: 2px 6px;
  }

  .detail-recharge em{
    background: #FE2746;
    color:#FFF;
    font-weight: 600;
    text-align: center;
    line-height: 36px;
    padding:9px 8px;
    border-bottom-left-radius: 5px;
    border-top-left-radius: 5px;
  }
  .detail-recharge i{
    color:#FE2746;
    float: right;
    padding:8px;
    font-size:14px;
  }
  .detail-evaluate img{
    width:20px;
    height:20px;
    border-radius: 50%;
  }
  .detail-evaluate,.detail-shop{
    width: 94%;
    margin: 0 auto;
    display: inline-block;
    margin-left: 3%;
    padding-top: 3%;
  }
  .detail-evaluate-img{
    width:12%;
    float:left;
    text-align: center;
  }
  .detail-evaluate-text{
    width: 88%;
    float: left;
    padding-bottom: 3%;
    border-bottom: 1px solid #f2f2f2;
  }
  .detail-evaluate-text p:nth-child(1){
    color:#999;
    font-size:15px;
  }
  .detail-evaluate-text p:nth-child(2){
    font-size:12px;
    margin-top:8px;
  }
  .detail-shop{
    padding-bottom: 3%;
  }
  .detail-shop img{
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-top: 7px;
  }
  .detail-shop-img{
    width:20%;
    float: left;
  }
  .detail-shop-text{
    width:80%;
    float: left;
  }
  .detail-shop-text-tel{
    font-size:16px;
  }
  .detail-shop-text-tel a{
    text-align: center;
    font-size: 12px;
    background: #FE2746;
    color: #FFF;
    border-radius: 20px;
    padding: 3px 9px;
    float: right;
  }
  .detail-shop-text-other{
    margin-top:10px;
  }
  .detail-shop-text-other span{
    color:#999;
    font-size:12px;
  }
  .detail-shop-text-other span:nth-child(2){
    margin:0 2%;
  }
  .detail-shop-text-other span em{
    color:#FE2746;
    font-size:12px;
  }
  .detail-info img{
    width:100%;
  }
  .detail-footer,.team-footer,.footer{
    position: fixed;
    bottom:0;
    left:0;
    height:48px;
    width:100%;
    background: #EBEBEB;
  }
  .detail-footer a:nth-child(1),.team-footer a:nth-child(1){
    width:20%;
    float: left;
    text-align: center;
  }
  .detail-footer a:nth-child(1) i,.team-footer a:nth-child(1) i{
    display: inline-block;
    height: 21px;
    width: 22px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//index.png)  no-repeat;
    background-size:100%;
    margin-top:5px;
  }
  .detail-footer a:nth-child(2) i,.team-footer a:nth-child(2) i{
    display: inline-block;
    height: 21px;
    width: 22px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//kefu.png)  no-repeat;
    background-size:100%;
    margin-top:5px;
  }
  .detail-footer a:nth-child(2),.team-footer a:nth-child(2){
    width:20%;
    float: left;
    text-align: center;
  }
  .detail-footer a:nth-child(3) i{
    display: inline-block;
    height: 21px;
    width: 22px;
    overflow: hidden;
    margin-top: 2px;
    background: url(../../../assets//shop.png)  no-repeat;
    background-size:100%;
    margin-top:5px;
  }
  .detail-footer a:nth-child(3){
    width:20%;
    float: left;
    text-align: center;
  }
  .detail-footer a:nth-child(4){
    width:40%;
    float: left;
    background: #FE2746 ;
    color:#FFF;
    text-align: center;
    height: 48px;
    line-height: 48px;
    height:48px;
    color:#FFF;
  }

















  /*选择规格*/
  .black{
    position: fixed;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9;
    display: none;
  }
  .footer-standard{
    position: fixed;
    bottom:0;
    left:0;
    width:100%;
    background: #FFF;
    border-top-right-radius: 5px;
    border-top-left-radius: 5px;
    z-index: 10;
    overflow: hidden;
    display: none;
  }
  .footer-standard-shop{
    width:94%;
    margin:3% auto;
  }
  .footer-standard-shop img{
    width:92px;
    height:92px;
    border-radius: 5px;
    float: left;
  }
  .footer-standard-shop div{
    margin-left: 10px;
    display: inline-block;
    margin-top:15px;
  }
  .footer-standard-shop div p:nth-child(1){
    color:#FE2746;
    font-size:16px;
  }
  .footer-standard-shop div p:nth-child(1) em{
    color:#FE2746;
    font-size:18px;
  }
  .footer-standard-shop div p:nth-child(2) em{
    color:#999;
  }
  .footer-standard-shop div p:nth-child(2){
    font-size:12px;
  }
  .detail-btn{
    width:100%;
    color:#FFF;
    background:#FE2746;
    height:49px;
    text-align: center;
    border:0;
    margin-top: 40px
  }
  .footer-standard-num{
    margin-top:15px;
    width:94%;
    margin-left: 3%;
    display: inline-block;
  }
  .footer-standard-num p{
    font-size:16px;
  }
  .footer-standard-num div em{
    padding: 3px 10px;
    border-radius: 20px;
    background-color: rgba(123, 123, 123, 0.08);
    text-align: center;
    margin-top: 15px;
    display: inline-block;
    margin-left: 6px;
  }
  .footer-standard-num-pink{
    background-color: rgba(254, 39, 70, 0.08) !important;
    color:#FE2746;
  }


















  /*添加地址*/
  .order-add-info-add span{
    color:#999;
  }
  .order-user{
    width:94%;
    margin:3%;
    display: inline-block;
  }
  .order-add-user{
    height:38px;
  }
  .order-add-user-textarea{
    margin-top:10px;
  }
  .order-add-user label{
    width:70px;
    line-height: 38px;
    float: left;
    display: inline-block;
  }
  .order-add-user-textarea label{
    width: 70px;
    display: inherit;
    float: left;
  }
  .order-add-user-textarea textarea{
    padding: 0px 9px;
    width: 71%;
    border: 0;
    height: 38px;
    font-weight: 600;
  }
  .order-add-user input{
    padding: 9px;
    width: 71%;
    border:0;
    font-weight: 600;
  }
  .order-add-user span{
    width: 75%;
    display: inline-block;
    float: left;
    margin-top:9px;
  }
</style>

